package Basics;

class myArray {
    private int arr[];
    private int All;
    private int max;
    private int min;

    public myArray(){}

    public myArray(int arr[]){
        this.arr = arr;
    }

    public void setArray(int arr[]){
        this.arr = arr;
    }

    public void addAll(){
        for (int i = 0; i < arr.length; i++){
            All += arr[i];
        }
        System.out.println(All);
    }

    public void ShowAll(){
        for (int i = 0; i < arr.length; i++){
            System.out.print(arr[i] + " ");
        }
        System.out.println();
    }

    public int max(){
        max = arr[0];
        int index = 0;
        for (int i = 1; i < arr.length; i++){
            if (arr[i] > max){
                max = arr[i];
                index = i;
            }
        }
        System.out.println(index);
        return max;
    }

    public int min(){
        min = arr[0];
        int index = 0;
        for (int i = 1; i < arr.length; i++){
            if (arr[i] < min){
                min = arr[i];
                index = i;
            }
        }
        System.out.println("min" + index);
        return min;
    }

}


public class 数组Array {
    public static void main(String[] args) {
        myArray ma = new myArray();
        ma.setArray(new int[]{1,5,4,8,2,1,3,85,4,6,8,41,5,1,5,456,48,723,12,4,21,4,24,564,45,261,56,424,1,521,16,45,4,5,45,4,46,4,54,5,4,5,45,4,54,5,45,1});
        ma.ShowAll();
        ma.addAll();
        System.out.println(ma.max());
        System.out.println(ma.min());
    }
}
